﻿using System;
using System.Collections.Generic;
using System.Linq;
using WholesaleOnline.Model;

namespace WholesaleOnline.Controller.Extension
{
    public static class AttributeExtensionMethod
    {
        public static IEnumerable<dynamic> ConvertToCategoryJsonModel(this IEnumerable<WoAttribute> categories, Dictionary<Guid, bool> displayCategoryIds)
        {
            return categories.Where(c => displayCategoryIds.ContainsKey(c.Id)).Select(c => new
            {
                id = c.Id,
                name = c.Name,
                children = c.Children.ConvertToCategoryJsonModel(displayCategoryIds)
            });
        }
    }
}
